Skip to content

[vm-repair] Return command warnings in the output payload (2.4.3) - #10340

Merged
Ethan Yang (necusjz) merged 1 commit into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-create-warnings
Sep 16, 2026
Merged

Ethan Yang (necusjz) merged 1 commit into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-create-warnings

Conversation

@EdwinBernal1

@EdwinBernal1 Edwin Bernal Microsoft (EdwinBernal1) commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

Summary

vm-repair 2.4.3. Advisory warnings raised by a command are now returned in its output under a warnings key, not only written to the log.

The problem

az vm repair create warns when the repair VM size supports NVMe but not SCSI:

The repair VM size only supports NVMe. Repair scripts that select disks by the SCSI model string will not find the attached OS disk. Use --size to pick a size that supports SCSI, or verify the script handles NVMe.

That warning is real and consequential — several repair scripts in Azure/repair-script-library locate the attached OS disk by its SCSI model name, and on an NVMe-only repair VM they find nothing, complete, and report success. But the warning only ever reached the log. The returned JSON was a plain success payload:

{ "status": "SUCCESS", "repair_vm_name": "repair-scr5", ... }

So a script, harness, or portal experience driving az vm repair create had no way to know that the repair VM it just created is one that several repair scripts cannot work on. The only way to find out was to scrape stderr.

This surfaced during the PR #153 validation run in Azure/repair-script-library, where the warning fired on a Standard_D2ads_v6 repair VM and was visible to a human but not to the harness.

Changes

  • azext_vm_repair/command_helper_class.py — the command helper carries a warnings list, and init_return_dict includes it. The key is omitted when there are no warnings, so existing output is byte-for-byte unchanged for every command that raises none.
  • azext_vm_repair/custom.py — create records the disk-controller warning when the selection produces one. The log line is unchanged; this adds to the payload rather than moving anything.
  • azext_vm_repair/tests/latest/test_returned_warnings.py — new.
  • setup.py, HISTORY.rst — version and changelog.

Version & changelog

  • setup.py VERSION: 2.4.2 -> 2.4.3
  • HISTORY.rst entry added: yes

Testing

python -m unittest azext_vm_repair.tests.latest.test_returned_warnings \
                   azext_vm_repair.tests.latest.test_disk_controller_type \
                   azext_vm_repair.tests.latest.test_repair_utils
Ran 32 tests — OK

test_returned_warnings.py covers the three things that matter: the key is absent when nothing was raised, a raised warning comes back, and the returned list is a copy so a caller mutating it cannot corrupt the helper's state.

Run with the Azure CLI's bundled Python under unittest. azdev style and azdev linter were not run locally — azdev is not on the PATH in this environment, so CI will be the first to exercise them.

No live Azure tests were run.

Cross-repo impact (repair-script-library)

None. No run id, script path, or map.json change.

Security review

No new input handling. The only value added to the payload is a fixed message the extension itself produced; no caller-supplied string, resource name, or tag reaches it.

Backward compatibility

Additive. No command, parameter, default, or existing output key changes. A consumer that does not know about warnings sees exactly what it saw before, because the key only appears when a warning was raised.

az vm repair create warns when the repair VM size supports NVMe but not SCSI, because repair scripts that locate the attached OS disk by its SCSI model name will not find it there. That warning only ever reached the log, so a script or portal driving the command got a success payload with no way to know the repair VM it just created is one several repair scripts cannot work on. Warnings now also appear under a warnings key, which is omitted when there are none so existing output is unchanged.

Raised by the PR 153 validation run in Azure/repair-script-library.
Copilot AI lite review requested due to automatic review settings September 15, 2026 18:48
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Edwin Bernal Microsoft (@EdwinBernal1),
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Warning propagation and test coverage/teardown issues remain unresolved.

Pull request overview

Updates vm-repair 2.4.3 to expose command warnings in output payloads.

Changes:

  • Tracks and conditionally returns warnings.
  • Captures disk-controller warnings during VM creation.
  • Adds warning tests and updates version history.
File summaries
File Summary
src/vm-repair/setup.py Version bump to 2.4.3.
src/vm-repair/HISTORY.rst Documents the warning payload change.
src/vm-repair/azext_vm_repair/tests/latest/test_returned_warnings.py Tests warning behavior; teardown handling and defensive-copy coverage require correction.
src/vm-repair/azext_vm_repair/custom.py Records disk-controller warnings; propagation, deprecation-warning coverage, and create-path testing require changes.
src/vm-repair/azext_vm_repair/command_helper_class.py Adds warning tracking and conditional payload serialization.
Review details

Suppressed comments (5)

src/vm-repair/azext_vm_repair/custom.py:340

  • Because create() is also called by repair_and_restore() and repair_button(), this appends the warning only to the nested helper's payload. Those callers currently log create_out and then build a new outer payload without copying create_out['warnings'], so the same NVMe-only condition is still invisible to users of those commands. Propagate create_out.get('warnings', []) into the outer command before its init_return_dict(), or explicitly scope this feature to direct vm repair create.
            command.warnings.append(message)

src/vm-repair/azext_vm_repair/custom.py:340

  • The added tests exercise init_return_dict with a manually populated list, but none execute this create branch. A regression that drops or misroutes this append would still pass while az vm repair create returned no warning; add a mocked create-path test that forces the selector to return a warning and asserts the final payload contains it.
        if level == 'warning':
            command.warnings.append(message)

src/vm-repair/azext_vm_repair/custom.py:340

  • The payload is still incomplete for the contract described in the PR: create also emits the --yes deprecation warning at custom.py:198, but only the disk-controller warning is appended here. A caller using warnings therefore misses a warning emitted by the same command; either record every warning covered by the contract or narrow the stated guarantee.
        if level == 'warning':
            command.warnings.append(message)

src/vm-repair/azext_vm_repair/tests/latest/test_returned_warnings.py:20

  • These patches are active only while constructing helper; after the context exits, the returned object is finalized with the real command_helper.__del__, even though __init__ was skipped. The destructor reads missing attributes such as is_verbose and cmd, producing an ignored AttributeError/unraisable teardown warning for each test. Use a test subclass with a no-op destructor or otherwise avoid returning a partially initialized production object.
        with mock.patch.object(command_helper, '__init__', return_value=None), \
                mock.patch.object(command_helper, '__del__', lambda self: None):

src/vm-repair/azext_vm_repair/tests/latest/test_returned_warnings.py:41

  • This test mutates helper.warnings after creating the return value, so it only checks that the payload is a snapshot. It never verifies the defensive-copy direction promised by the test name: a caller could append to returned and corrupt helper.warnings if the original list were returned. Mutate returned instead and assert that helper.warnings remains unchanged.
        returned = helper.init_return_dict()['warnings']
        helper.warnings.append('second')
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@necusjz
Ethan Yang (necusjz) merged commit 3471017 into Azure:main Sep 16, 2026
44 checks passed
@azclibot

Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ vm-repair-2.4.3 ] : https://dev.azure.com/msazure/One/_build/results?buildId=181366000&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants